home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2005 October
/
PCWOCT05.iso
/
Software
/
FromTheMag
/
Syn Text Editor 2.1.0.46
/
synsetup-2.1.0.46.exe
/
{app}
/
scripts
/
img_src.vbs
< prev
next >
Wrap
Text File
|
2003-08-13
|
2KB
|
90 lines
' Caption: Insert IMG tag|
' Hint: Insert an IMG SRC tag|
' Icon: img_src.ico|
'
' img src tag.
'
' The contents of this file are subject to the Mozilla Public License
' Version 1.1 (the "License"); you may not use this file except in compliance
' with the License. You may obtain a copy of the License at
' http://www.mozilla.org/MPL/
'
' Software distributed under the License is distributed on an "AS IS" basis,
' WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
' the specific language governing rights and limitations under the License.
'
' The Initial Developer of the Original Code is Magoga Demis.
' Portions created by Magoga Demis are Copyright (C) 2000-2003 Magoga Demis.
' All Rights Reserved.
'
' $Id: img_src.vbs,v 1.2.2.5 2003/08/13 00:38:45 neum Exp $
'
option explicit
'#include <cmnfunc>
on error resume next
' non togliere il parametro dummy
sub Main(FileName)
' vars
dim image
dim pic
dim file
dim divX
dim divY
dim dlg
dim pos
dim l1
dim l2
dim docPath
dim refPic
if Documents.Count = 0 then
exit sub
end if
'ref pic to calculate twips
Set refPic=LoadPicture(AddBackslash(ExtractFilePath(FileName)) & "1000x1000.gif")
'Assume the reference picture is in the path from the script, not relative to
'the program, more secure, I think.
'get scale
divX=refPic.width/1000
divY=refPic.height/1000
'chose the image to insert
Set dlg=Create("TOpenDialog", Self)
dlg.Title="Choose a picture"
dlg.Filter="Pictures (*.jpg,*.gif)|*.jpg;*.gif|All Files (*.*)|*.*"
if not dlg.Execute then
exit sub
end if
'file name
file=dlg.FileName
'load pic
Set pic=LoadPicture(file)
docPath=ActiveDocument.FilePath & "\"
'index of curr dir
pos=inStr(file, docPath)
'in a sub dir calculate relative path
if pos<>0 then
l1=Len(docPath)
l2=Len(file)
file=Right(file, l2-l1)
end if
'no \ but /
file=Replace(file, "\", "/")
'write the tag
ActiveDocument.SelText= "<img src=""" & file & """ border=""0"" width=""" & Round(pic.width/divX, 0) & """ height=""" & Round(pic.height/divY, 0) & """>"
end sub